Hi everyone,
I can't find detailed instruction on how to understand the use of context and data in handle_data to access fetched data.
I have some specific questions related to the following example below:
def initialize(context):
# a signal Fetcher
fetch_csv('http://priceoftea.com/', symbol='tea')
# a security info Fetcher
fetch_csv('http://insiderselling.com')
why does not use the following code here?
context.stock = symbol('XYZ')
def handle_data(context, data):
# guard against being called before the first trade of a security
if symbol('XYZ') in data:
# guard against trades happening before the first insider selling event
if 'insider' in data[symbol('XYZ')]:
if data[symbol('XYZ')]['insider'] > 10.0:
order(symbol('XYZ'), -100)
# signal data will pass a blank place holder if the first event has not been sent yet.
# So, you can just guard against missing properties
if 'price' in data['tea']:
record(price_of_tea=data['tea']['price'])
does
symbol('XYZ')data come from site 'http://insiderselling.com'?how
contextanddatadifferentiate from each other?
what are the jobs ofcontextanddata?
how do they complete their jobs differently?
also,datacan not be used to calculate custom indicator, we have to usecontext.stock, is it right?